/*************************************************************************
	> File Name: B2136.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-15 13:40:06
 ************************************************************************/

#include <iostream>
#include <cmath>
using namespace std;

int is_prime(int n) {
    for (int i = 2, I = sqrt(n); i <= I; i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int is_reverse(int n) {
    string s = to_string(n);
    int i = 0, j = s.size() - 1;
    while (i < j) {
        if (s[i] != s[j]) return 0;
        i++, j--;
    }
    return 1;
}

int check(int n) {
    return is_reverse(n) && is_prime(n);
}

int main() {
    int n, cnt = 0;
    cin >> n;
    for (int i = 11; i <= n; i++) {
        cnt += check(i);
    }
    cout << cnt << endl;
    return 0;
}
